export default {
	namespaced: true, // 命名空间
	// 状态
	state: {
		token: uni.getStorageSync('token') || '',
		address: uni.getStorageSync("address") ||  {},
		userInfo: uni.getStorageSync("userInfo") || {},
		redirectInfo: null
	},
	// 修改state状态的唯一途径
	mutations: {
		updateAddress(state, address) {
			state.address = address
			uni.setStorageSync("address", address)
		},
		updateUserInfo(state, userInfo) {
			state.userInfo = userInfo
			uni.setStorageSync("userInfo", userInfo)
		},
		 updateToken(state, token) {
		    state.token = token || ''
		    uni.setStorageSync('token', state.token)
		  },
			  setRedirectInfo(state, info) {
			    state.redirectInfo = info
			  },
	},
	// 处理异步
	actions: {},
	// 基于state派生新的状态
	getters: {
		fullAddress(state) {
			const { provinceName, cityName, countyName, detailInfo  } = state.address
			if (!provinceName) return ''
			return provinceName+cityName+countyName+detailInfo
		}
	}
}